//
//  UFAPI.m
//  universityFace
//
//  Created by 阮 沧晖 on 14-9-25.
//  Copyright (c) 2014年 阮 沧晖. All rights reserved.
//

#import "UFAPI.h"
//服务器IP
NSString *const hostIp = @"http://app.dd5s.com:8080";
//NSString *const hostIp = @"http://192.168.1.123:8080";
//NSString *const hostIp = @"http://test.dd5s.com:8080";

#pragma mark -认证
//获取token
NSString *const apiAuthToken = @"/oauth/token";
//退出登录
NSString *const apiLoginOut = @"/api/logout";

#pragma mark -用户相关
//获取当前用户信息
NSString *const apiGetUserInfo = @"/api/user/me";
//查询是否有绑定第三方账号
NSString *const apiIsBind = @"/api/user/open/is-bind";
//绑定第三方账号
NSString *const apiBind = @"/api/user/open/bind";
//检查是否为注册用户
NSString *const apiIsOpen = @"/api/user/is-open";
//获取手机验证码
NSString *const apiPhoneCode = @"/api/user/phone-code";
//重置用户密码
NSString *const apiResetPassword = @"/api/user/password/reset";
//注册用户
NSString *const apiUserResiter = @"/api/user/register";
//修改用户信息
NSString *const apiUserEdit = @"/api/user/edit";
//修改用户密码
NSString *const apiPasswordChange = @"/api/user/password/change";
//修改用户头像
NSString *const apiAvatarSave = @"/api/user/avatar/save";
//获取用户头像地址
NSString *const apiUserAvatar = @"/api/user/avatar/"; ///api/user/avatar/{uid}
//批量获取用户头像地址
NSString *const apiAvatarGet = @"/api/user/avatar/get";
//更新用户心情
NSString *const apiRecentSave = @"/api/user/recent/save";
//分享纪录
NSString *const apiDailyShare = @"/api/user/daily-share";
//每日签到
NSString *const apiDailySign = @"/api/user/daily-sign";


#pragma mark -主业务
NSString *const apiTopicList = @"/api/topic/list";
//获取我的科目列表
NSString * const apiDefaultCourseList = @"/api/course/default/list";
NSString * const apiCoursetList = @"/api/course/list";
NSString * const apiCourseAdd = @"/api/course/add";
NSString * const apiAnswerSave = @"/api/question/answer/save";
NSString * const apiMarkSave = @"/api/topic/mark/save";
NSString * const api_click_like_and_cancel = @"/api/extend/praise";
NSString * const apiMarkRemove = @"/api/topic/mark/remove";
NSString * const apiQuestionList = @"/api/question/list";
NSString * const apiTopicSave = @"/api/topic/save";
//保存题目
NSString * const apiQuestionSave = @"/api/question/save";
//获取我的发布列表
NSString * const apiMyTopicList = @"/api/my/topic/list";
//获取发布的详情
NSString * const apiTopicDetail = @"/api/topic/detail";
//修改发布
NSString * const apiTopicEdit = @"/api/topic/edit";
//修改科目
NSString * const apiCourseEdit = @"/api/course/edit";
//增加用户题目标签
NSString * const apiTopicTagAdd = @"/api/topic/tag/add";
//收藏列表
NSString * const apiMarkList = @"/api/topic/mark/list";
//获取我的回答列表
NSString *const apiAnswerList = @"/api/my/answer/list";
//获取作答统计
NSString *const apiAnswerStat = @"/api/topic/answer/stat";
//获取答题列表
NSString *const apiAnswerUser = @"/api/topic/answer/user";
//获取用户回答列表
NSString *const apiQuestionAnswerList = @"/api/question/answer/list";
//对作答进行评分
NSString * const apiQuestionAnswerEvaluate = @"/api/question/answer/evaluate";
//追问
NSString * const apiQuestionAnswerReply = @"/api/question/answer/reply";
//获取追问列表
NSString *const apiQuestionAnswerReplyList = @"/api/question/answer/reply/list";
//采纳答案
NSString * const apiQuestionAnswerAdopt = @"/api/question/answer/adopt";
//作答提交（目前提交后只处理下发推送的功能）
NSString * const apiAnswerSubmit = @"/api/topic/answer/submit";
#pragma mark -通用接口
NSString *const apiSystime = @"/api/systime";
NSString *const apiUpload = @"/api/upload/file";
NSString *const apiUploadIMG = @"/api/upload/img";
NSString *const apiAdList = @"/api/ad/list";
NSString *const apiCommonFeekback = @"/api/feedback/save";
NSString *const apiCommonAbout = @"/api/about";
NSString *const apiCommonCheckVersion = @"/api/check-update";

#pragma mark - 积分
NSString *const apiQueryIntegral = @"/api/gift/query/integral";
NSString *const apiGifGave = @"/api/gift/give";
NSString *const apiGiftQuery = @"/api/gift/query/integral/log";

#pragma mark - 礼品
NSString *const apiMGiftQuery = @"/api/gift/query/gift";
NSString *const apiMGifOrderQuery = @"/api/gift/query/order";
NSString *const apiGiftExchange = @"/api/gift/change";

#pragma mark - 收货地址
NSString *const apiQueryAddress = @"/api/user/my/recipient/list";
NSString *const apiAddAddress = @"/api/user/my/recipient/add";
NSString *const apiUpdateAddress = @"/api/user/my/recipient/edit";
@implementation UFAPI

+ (UFAPI *)shared
{
    static UFAPI *_api = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _api = [[self alloc] init];
    });
    return _api;
}


-(NSString *)urlStringWithModuleAuthTag:(DDAuthTag)tag
{
    NSString *tempStr = nil;
    switch (tag) {
        case kDDAuthToken:
            tempStr = apiAuthToken;
            break;
        case kDDLoginOut:
            tempStr = apiLoginOut;
            break;
        default:
            break;
    }
    
    tempStr = [NSString stringWithFormat:@"%@%@",hostIp,tempStr];
    return tempStr;
    
}
-(NSString *)urlStringWithModuleUserTag:(DDUserTag)tag
{
    NSString *tempStr = nil;
    switch (tag) {
        case kDDGetUserInfo: //获取当前用户信息
            tempStr = apiGetUserInfo;
            break;
        case kDDIsBind:          //查询是否有绑定第三方账号
            tempStr = apiIsBind;
            break;
        case kDDBind:            //绑定第三方账号
            tempStr = apiBind;
            break;
        case kDDIsOpen:          //检查是否为注册用户
            tempStr = apiIsOpen;
            break;
        case kDDUserPhoneCode:   //获取手机验证码
            tempStr = apiPhoneCode;
            break;
        case kDDResetPassword:   //重置用户密码
            tempStr = apiResetPassword;
            break;
        case kDDUserRegister:    //注册用户
            tempStr = apiUserResiter;
            break;
        case kDDUserEdit:        //修改用户信息
            tempStr = apiUserEdit;
            break;
        case kDDPasswordChange:  //修改用户密码
            tempStr = apiPasswordChange;
            break;
        case kDDAvatarSave:      //修改用户头像
            tempStr = apiAvatarSave;
            break;
        case kDDUserAvatar:      //获取用户头像地址
            tempStr = apiUserAvatar;
            break;
        case kDDAvatarGet:       //批量获取用户头像地址
            tempStr = apiAvatarGet;
            break;
        case kDDRecentSave:      //更新用户心情
            tempStr = apiRecentSave;
            break;
        case kDDDailyShare:      //分享纪录
            tempStr = apiDailyShare;
            break;
        case kDDDailySign://每日签到
            tempStr = apiDailySign;
            break;
    }
    tempStr = [NSString stringWithFormat:@"%@%@",hostIp,tempStr];
    return tempStr;
    
}


-(NSString *)urlStringWithModuleMainTag:(DDMainTag)tag
{
    NSString *tempStr = nil;
    switch (tag) {
        case kDDTopicList:
            tempStr = apiTopicList;
            break;
        case kDDCoursetList:
            tempStr = apiCoursetList;
            break;
        case kDDQuestionSave:
            tempStr = apiQuestionSave;
            break;
        case kDDQuestionList:
            tempStr = apiQuestionList;
            break;
        case kDDAnswerSave:
            tempStr = apiAnswerSave;
            break;
        case kDDMarkSave:
            tempStr = apiMarkSave;
            break;
        case click_like_and_cancel:
            tempStr = api_click_like_and_cancel;
            break;
        case kDDMarkRemove:
            tempStr = apiMarkRemove;
            break;
        case kDDTopicSave:
            tempStr = apiTopicSave;
            break;
        case kDDAddCourse:
            tempStr = apiCourseAdd;
            break;
        case kDDMarkList:
            tempStr = apiMarkList;
            break;
        case kDDAnswerList:
            tempStr = apiAnswerList;
            break;
        case kDDMyTopicList:
            tempStr = apiMyTopicList;
            break;
        case kDDAnswerStat:
            tempStr = apiAnswerStat;
            break;
        case kDDAnswerUser:
            tempStr = apiAnswerUser;
            break;
        case kDDQuestionAnswerList://获取作答列表
            tempStr = apiQuestionAnswerList;
            break;
        case kDDQuestionAnswerReplyList:
            tempStr = apiQuestionAnswerReplyList;
            break;
        case kDDQuestionPublishDetail:
            tempStr = apiTopicDetail;
            break;
        case kDDQuestionTopicEdit:
            tempStr = apiTopicEdit;
            break;
        case kDDQuestionCourseEdit:
            tempStr = apiCourseEdit;
            break;
        case kDDQuestionTopicTagAdd:
            tempStr = apiTopicTagAdd;
            break;
        case kDDQuestionAnswerEvaluate:
            tempStr = apiQuestionAnswerEvaluate;
            break;
        case kDDQuestionAnswerReply:
            tempStr = apiQuestionAnswerReply;
            break;
        case kDDQuestionAnswerAdopt:
            tempStr = apiQuestionAnswerAdopt;
            break;
        case kDDAnswerSubmit:
            tempStr = apiAnswerSubmit;
            break;
        case kDDDefaultCourseList:
            tempStr = apiDefaultCourseList;
            break;
        default:
            break;
    }
    tempStr = [NSString stringWithFormat:@"%@%@",hostIp,tempStr];
    return tempStr;
    
}


- (NSString *)urlStringWithGeneralTag:(DDCommonTag)tag;
{
    NSString *tempStr = nil;
    switch (tag) {
        case kDDUpload:
            tempStr = apiUpload;
            break;
        case kDDUploadIMG:
            tempStr = apiUploadIMG;
            break;
        case kDDAdList:
            tempStr = apiAdList;
            break;
        case kCommonFeekback:
            tempStr = apiCommonFeekback;
            break;
        case kCommonAbout:
            tempStr = apiCommonAbout;
            break;
        case kCommonCheckVersion:
            tempStr = apiCommonCheckVersion;
            break;
        case KUFGetSystime:
            tempStr = apiSystime;
            break;
        default:
            break;
    }
    //    if ([hostIp isEqualToString:@"http://192.168.1.123:8080"]) {
    //        tempStr = [NSString stringWithFormat:@"http://app.dd5s.com:8080%@",tempStr];
    //    }else{
    tempStr = [NSString stringWithFormat:@"%@%@",hostIp,tempStr];
    //    }
    return tempStr;
    
}

-(NSString *)urlStringWithModuleIntegralTag:(DDIntegralTag)tag
{
    NSString *tempStr = nil;
    switch (tag) {
        case kIntegralQuery:
            tempStr = apiQueryIntegral;
            break;
        case kDDGifGave:
            tempStr = apiGifGave;
            break;
        case kDDGiftQuery:
            tempStr = apiGiftQuery;
            break;
        default:
            break;
    }
    tempStr = [NSString stringWithFormat:@"%@%@",hostIp,tempStr];
    return tempStr;
    
}

//礼品
-(NSString *)urlStringWithGiftTag:(DDGiftTag)tag
{
    NSString *tempStr = nil;
    switch (tag) {
        case kGiftQuery:
            tempStr = apiMGiftQuery;
            break;
        case kGiftOrderQuery:
            tempStr = apiMGifOrderQuery;
            break;
        case kGiftExchange:
            tempStr = apiGiftExchange;
            break;
        default:
            break;
    }
    tempStr = [NSString stringWithFormat:@"%@%@",hostIp,tempStr];
    return tempStr;
    
}

//收货地址
-(NSString *)urlStringWithAddressTag:(DDAddressTag)tag
{
    NSString *tempStr = nil;
    switch (tag) {
        case kAddressQuery:
            tempStr = apiQueryAddress;
            break;
        case kAddressAdd:
            tempStr = apiAddAddress;
            break;
        case kAddressUpdate:
            tempStr = apiUpdateAddress;
            break;
        default:
            break;
    }
    tempStr = [NSString stringWithFormat:@"%@%@",hostIp,tempStr];
    return tempStr;
}


@end
